package com.ruoyi.training.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.training.domain.ClassPaymentSettlement;
import com.ruoyi.training.service.IClassPaymentSettlementService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 班级费用结算Controller
 * 
 * @author lqx
 * @date 2025-10-30
 */
@RestController
@RequestMapping("/classPaymentSettlement")
public class ClassPaymentSettlementController extends BaseController
{
    @Autowired
    private IClassPaymentSettlementService classPaymentSettlementService;

    /**
     * 查询班级费用结算列表
     */
//    @RequiresPermissions("training:classPaymentSettlement:list")
    @GetMapping("/list")
    public TableDataInfo list(ClassPaymentSettlement classPaymentSettlement)
    {
        startPage();
        List<ClassPaymentSettlement> list = classPaymentSettlementService.selectClassPaymentSettlementList(classPaymentSettlement);
        return getDataTable(list);
    }

    /**
     * 导出班级费用结算列表
     */
    @RequiresPermissions("training:classPaymentSettlement:export")
    @Log(title = "班级费用结算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClassPaymentSettlement classPaymentSettlement)
    {
        List<ClassPaymentSettlement> list = classPaymentSettlementService.selectClassPaymentSettlementList(classPaymentSettlement);
        ExcelUtil<ClassPaymentSettlement> util = new ExcelUtil<ClassPaymentSettlement>(ClassPaymentSettlement.class);
        util.exportExcel(response, list, "班级费用结算数据");
    }

    /**
     * 获取班级费用结算详细信息
     */
    @RequiresPermissions("training:classPaymentSettlement:query")
    @GetMapping(value = "/{classPaymentSettlementId}")
    public AjaxResult getInfo(@PathVariable("classPaymentSettlementId") String classPaymentSettlementId)
    {
        return success(classPaymentSettlementService.selectClassPaymentSettlementByClassPaymentSettlementId(classPaymentSettlementId));
    }

    /**
     * 新增班级费用结算
     */
    @RequiresPermissions("training:classPaymentSettlement:add")
    @Log(title = "班级费用结算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClassPaymentSettlement classPaymentSettlement)
    {
        return toAjax(classPaymentSettlementService.insertClassPaymentSettlement(classPaymentSettlement));
    }

    /**
     * 修改班级费用结算
     */
    @RequiresPermissions("training:classPaymentSettlement:edit")
    @Log(title = "班级费用结算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClassPaymentSettlement classPaymentSettlement)
    {
        return toAjax(classPaymentSettlementService.updateClassPaymentSettlement(classPaymentSettlement));
    }

    /**
     * 删除班级费用结算
     */
    @RequiresPermissions("training:classPaymentSettlement:remove")
    @Log(title = "班级费用结算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classPaymentSettlementIds}")
    public AjaxResult remove(@PathVariable String[] classPaymentSettlementIds)
    {
        return toAjax(classPaymentSettlementService.deleteClassPaymentSettlementByClassPaymentSettlementIds(classPaymentSettlementIds));
    }
}
